package com.naughty.userlogin02.controller;

import com.naughty.userlogin02.bean.Student;
import com.naughty.userlogin02.dao.StudentDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginSController {

    @Autowired
    StudentDao studentDao;

    @CrossOrigin
    @RequestMapping("/logins")
    public String studentLogin(@RequestBody Student student) {
        System.out.println("Student : " + student);
        String str = "error";
        int count = studentDao.getStudentByMassage(student.getSname(), student.getSpwd());
        if (count > 0) {
            str = "ok";
        }
        return str;
    }
}
